<?php
/**
 * 日志模型类
 * @author zengnz
 *
 */
class LogModel extends CommonModel
{
	protected $tableName = '';
	
	//每张表存的记录数
	private $countPerTable = 10000000;
	
	//添加内容
	const ADD = 1;
	//更新内容
	const UPDATE = 2;
	//删除内容
	const DEL = 3;
	
	public static function getTypes() {
		return array(
			self::ADD => '添加内容',
			self::UPDATE => '更新内容',
			self::DEL => '删除内容',				
		);
	}
	
	/**
	 * 添加管理员登录日志
	 */
	public function loginLog() {
		$data = array(
			'admin_id' => $this -> getLoginId(),
			'name' => $this -> getAccount(),
			'ip' => getIpAddress(),	
			'login_time' => time()				
		);	

		$ret = M('log_admin_login') -> data($data) -> add();
		if ($ret >= $this -> countPerTable) {
			//创建新表，记录表信息
		}
			
		
		return $ret;
	}
	
	/**
	 * 添加操作日志
	 */
	public function actionLog( $type, $summary ) {
		if (!$type || !$summary)
			return 0;
		$data = array(
			'admin_id' => $this -> getLoginId(),
			'name' => $this -> getAccount(),
			'action_time' => time(),
			'type' => $type,
			'summary' => $summary
		);
		
		$ret = M('log_admin_action') -> data($data) -> add();
		if ($ret >= $this -> countPerTable) {
			//创建新表，记录表信息
		}
		return $ret;
	}
	
	
	private function createLoginLogTable() {
		
	}
	
	private function createActionLogTable() {
	
	}
	
}